import axios from "axios";
import {quickPost} from "../util/common.ts";

const GET_CAPTCHA_API = "/api/getCaptcha"

const getCaptchaRequest = async () => {
    const response = await axios.post(GET_CAPTCHA_API);
    return response.data;
}

const USER_LOGIN_API = "/api/userLogin"

const loginRequest = async (account: string, password: string, captcha: string) =>{
    const formData = new FormData();
    formData.append("account", account);
    formData.append("password", password);
    formData.append("captcha", captcha);
    return await quickPost(USER_LOGIN_API, formData);
}

const GET_LOGIN_INFO_API = "/api/getLoginInfo"

const getLoginInfoRequest = async () => {
    return await quickPost(GET_LOGIN_INFO_API);
}

export {
    getCaptchaRequest,
    loginRequest,
    getLoginInfoRequest
};
